#!/usr/bin/env python

import os
import sys

sys.path.append('..')

from scato.ui.examples import examples


def save_dir(e, curdir):
    nn = 0
    for n, v in e:
        n = n.replace(' ', '_')
        uname = '%s/%02d-%s' % (curdir, nn, n)
        if hasattr(v, 'upper'):
            f = file(uname, 'w')
            f.write(v)
            f.close()
            print 'cat > %s' % uname
        else:
            print 'mkdir %s' % uname
            os.mkdir(uname)
            save_dir(v, uname)
        nn += 1

save_dir(examples, '.')
